{include file="public/header"}
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>原因管理</title>
    <link rel="stylesheet" type="text/css" href="__CSS__/tt.css" />
    <style>

        html,body {
            width: 100%;
            background:rgba(238,238,238,1);
        }

        .container{
            padding-top:30px;
            padding-bottom:94px;
        }


        .box{
            width:1200px;
            height:auto;
            margin: 0 auto;
            padding-bottom:10px;
            background-color:#FFFFFF;
        }

        .box_1{
            padding-left:30px;
            padding-right:30px;
            height: 66px;
        }


        table{
            width:100%;
            padding-left:30px;
            padding-right:30px;
            text-align:left;
            border-spacing:0;
            color:#666666;
            font-size:12px;
        }

        th{
            max-width:50px;
            height:50px;
            line-height:20px;
            background-color:#F7F7F7;
            word-wrap:break-word;
            /*padding-left: 2px;*/
            /*padding-right: 2px;*/
        }
        th:nth-child(1){
            /*padding-left:30px;*/
        }
        th:nth-child(14){
            max-width:90px;
        }

        td{
            max-width:50px;
            height:50px;
            line-height:20px;
            border-bottom:1px solid #E9E9E9;
            word-wrap:break-word;
        }
        td:nth-child(1){
            /*padding-left:30px;*/
        }

        td:nth-child(13){
            max-width:90px;
        }

        .name111{
            width:24px;
            font-size:12px;
            font-weight:400;
            color:rgba(0,101,240,1);
            margin-right:7px;
            cursor: pointer;
        }

        .xia{

            font-weight:600;
            color:rgba(51,51,51,1);

        }


        .pagination{
            /*height: 28px !important;*/
            /*line-height:28px;*/
            /*margin-top:30px;*/
            /*padding-right:33px;*/
            color:#999;
            font-size:12px;
        }
        .pagination div{
            margin-left:5px;
            margin-right:5px;
        }
        .pagination div:nth-child(2){
            margin-right:15px;
        }
        .pagination div:nth-child(6){
            color:#282828;
        }
        .pagination div:nth-child(8){
            margin-left:15px;
        }
        .borderr{
            height:28px;
            width:28px;
            text-align:center;
            border-radius:2px;
            border:1px solid #F2F2F2;
        }
        .border_active{
            color:#FFFFFF;
            font-size:12px;
            background-color:#0065F0;
            height:28px;
            width:28px;
            text-align:center;
            border-radius:2px;
        }


        .box_1Name{
            color: #4A4A4A;
            width:56px;
            font-size:14px;
            font-weight:400;
            line-height:66px;
            padding-right: 30px;
        }

        .inputttt{
            margin-top:19px;
            width:230px;
            height:28px;
            background:rgba(255,255,255,1);
            border-radius:3px;
            border:1px solid rgba(244,244,244,1);
            color:rgba(204,204,204,1);
            font-size:12px;
        }

        .inputrenwu {
            padding-left: 11px;
            box-sizing: border-box;
            display: inline-block !important;
            width: 200px !important;
            height: 28px !important;
            outline: none;
            border-width: 0;
        }

        .inputtttImg{
            width: 16px;
            height: 16px;
            margin-top:6px;
            margin-left:5px;
        }

        .selectttt2{
            margin-top:19px;
            margin-left:30px;
            width:68px;
            height:28px;
            background:rgba(0,101,240,1);
            border-radius:3px;
            text-align: center;
            line-height:28px;
            font-size:12px;
            font-weight:400;
            color:rgba(255,255,255,1);
        }

        .selectttt3{
            margin-top:19px;
            width:100px;
            height:28px;
            line-height:28px;
            font-size:12px;
            font-weight:400;
            color:rgba(255,255,255,1);
            background:rgba(247,247,247,1);
            border-radius:3px;
            border:1px solid rgba(217,217,217,1);
            text-align: center;
            color: #999999;
        }

        .hidden{
            display: none
        }
    </style>
    <style>
        .header1{

            width:108px;
            text-align: center;
            color: #666666;
            line-height: 50px;
        }
        label{
            display:inline-block;
            height:50px;
            line-height:50px;
            text-align:center;
            position: relative;
        }
        label input{
            width: 1px;
            height: 1px;
            vertical-align: bottom;
            opacity: 0;
        }
        .ovfHiden{overflow: hidden;height: 100%;}
    </style>
</head>
<body>
<a name="miao"></a>
<div class="tt_top3">
    <div class="tt_top33">原因管理</div>
</div>
<div class="container">
    <div class="box">
        <form id="alls">
            <div class="box_1 flex-wrap" style="position: relative;">
                <div class="box_1Name">拒绝原因</div>
                <div class="inputttt flex-wrap">
                    <input type="text" class="inputrenwu" name="search[]" value="{$search.0?:''}" placeholder="搜索拒绝原因">
                    <img src="__IMG__/search.png" class="inputtttImg"/>
                </div>
                <div class="selectttt2 hand_icon" id="search">确定</div>
                <!--<div style="width: 100%;position: relative;">-->
                <div class="selectttt3" style="cursor: pointer;position: absolute;right: 30px" onclick="addrea();">添加</div>
                <!--</div>-->
            </div>
        </form>
        <div class="box1">
            <table>
                <tr>
                    <th>序号</th>
                    <th>拒绝原因</th>
                    <th>最后更新时间</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                {if condition="!$data->isEmpty()"}
                {foreach name="data" item="vo"}
                <tr>
                    <td>{:xuHao($key,$pages)}</td>
                    <td>{$vo.reason_name}</td>
                    <td>{$vo.reason_time}</td>
                    <td>
                        {if $vo.reason_status == 1}上架{/if}
                        {if $vo.reason_status == 2}下架{/if}
                    </td>
                    <td>
                        {if $vo.reason_status == 1}
                        <span class="name111 xiajia" data-id="{$vo.reason_id}">下架</span>
                        {/if}
                        {if $vo.reason_status == 2}
                        <span class="name111 shangjia" data-id="{$vo.reason_id}">上架</span>
                        {/if}
                        <span class="name111 edit" data-id="{$vo.reason_id}" data-con="{$vo.reason_name}">编辑</span>
                        <span class="name111 del" data-id="{$vo.reason_id}">删除</span>
                    </td>
                </tr>
                {/foreach}
                {else/}
                <tr>
                    <td colspan="13" style="text-align: center;">暂无数据 ！</span></td>
                </tr>
                {/if}

            </table>
        </div>
        <ul class="pagination flex-con" style="display: flex;justify-content: flex-end;">
            {$data->render()}
        </ul>
    </div>
</div>
<!--单独审核弹窗start-->
<style>
    textarea{
        width:100%;
        height:100px;
        overflow-y: auto;
        padding:0;
        border:1px solid #E9E9E9;
        background:rgba(0,0,0,0);
        border-radius:5px;
        padding:5px;
    }
    .container_one{
        width:520px;
        height:230px;
        background:#fff;
        box-shadow:0px 2px 8px 0px rgba(0,0,0,0.2);
        border-radius:5px 4px 4px 4px;
        position: fixed;
        top:0;
        left:0;
        right:0;
        bottom:0;
        margin:auto;
        z-index: 999;
    }
    .title{
        height:50px;
        line-height: 50px;
        font-size:16px;
        color:#333;
        padding-left:20px;
        border-bottom:1px solid #E9E9E9
    }
    .btnBox{
        width:100%;
        height:52px;
        position: absolute;;
        bottom:0;
        left:0;
        border-top:1px solid #E9E9E9;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        /*padding-top:10px;*/
    }
    button{
        width:88px;
        height:32px;
        line-height: 32px;
        text-align: center;
        font-size:14px;
        outline: none;
        border:0;
        margin-left:8px;
    }
    .cancel_one{
        border:1px solid #D9D9D9;
        border-radius:2px;
        background: rgba(0,0,0,0);
        color:#666666;
    }
    .sure_one{
        background:#2A63E7;
        border-radius:2px;
        color:#fff;
    }
</style>
<div class="container_one hidden">
    <div class="title">拒绝原因</div>
    <div class="content" style="padding-top: 10px">
        <textarea name="name" id="jj_reason_one" placeholder="请输入拒绝原因"></textarea>
    </div>
    <div class="btnBox">
        <button class="cancel_one">取 消</button>
        <button class="sure_one">确定</button>&nbsp;
    </div>
</div>
<!--单独审核弹窗-end-->
<input type="hidden" id="rrrid" value="" />
<div class="all_div" style="display:none;width: 100%;height: 100%;background-color: gray;position: fixed;z-index: 100;background: rgba(0,0,0,0.5);top: 0;left: 0;padding: 0;margin: 0;"></div>
</body>
{include file="public/footer"}
<script type="text/javascript" src="__JS__/api.js"></script>
<script type="text/javascript">
    /*筛选*/
    $("#search").click(function () {
        var data = $("#alls").serialize();
        window.location.href = '/shop/Reasons/reasons?' + data;
    });
    //添加时候，把id干掉，内容清空
    function addrea() {
        $('.container_one').removeClass('hidden');
        $('.all_div').css('display','block');
        $('html,body').addClass('ovfHiden');
        $('#rrrid').val('');
        $('#jj_reason_one').val('');
    }

    //编辑
    $(".edit").click(function () {
        var id = $(this).attr('data-id');
        var con = $(this).attr('data-con');
        $('#rrrid').val(id);
        $('#jj_reason_one').val(con);

        $('.container_one').removeClass('hidden');
        $('.all_div').css('display','block');
        $('html,body').addClass('ovfHiden');
    });
    //上架
    $(".shangjia").click(function () {
        if(confirm('确认上架吗？')){
            var id = $(this).attr('data-id');
            ajaxForThree(id,1);
        }
    });
    //上架
    $(".xiajia").click(function () {
        if(confirm('确认下架吗？')){
            var id = $(this).attr('data-id');
            ajaxForThree(id,2);
        }
    });
    //删除
    $(".del").click(function () {
        if(confirm('确认删除吗？')){
            var id = $(this).attr('data-id');
            ajaxForThree(id,3);
        }
    });
    function ajaxForThree(id,type) {
        $.ajax({
            url: '/shop/Reasons/upDownDel',
            data: 'reason_id=' + id + '&type=' + type,
            type: 'POST',
            dataType: 'JSON',
            success: function (returnData) {
                alert(returnData.msg);
                if(returnData.code == 200){
                    location.reload();
                }
            },
            error: function () {
                alert('数据出错，请刷新重试');
            }
        })
    }
</script>
<script>
    $('.cancel_one').click(function () {
        $('.container_one').addClass('hidden');
        $('.all_div').css('display','none');
        $('html,body').removeClass('ovfHiden');
    });
    $('.sure_one').click(function () {
        var id = $('#rrrid').val();
        var reason = $('#jj_reason_one').val().trim();
        if(reason == ''){
            alert('拒绝原因不能为空！');
            return false;
        }else{
            $.ajax({
                url: '/shop/Reasons/addOrEdit',
                data: 'reason_id='+id+'&reason='+reason,
                type: 'POST',
                dataType: 'JSON',
                success: function (returnData) {
                    alert(returnData.msg);
                    if(returnData.code == 200){
                        location.reload();
                    }
                },
                error: function () {
                    alert('数据出错，请刷新重试');
                }
            })
        }
    });

</script>
